package other;


import java.util.Scanner;

/**
 * Creared with IntelliJ IDEA.
 * Description:输入两个表示复数的字符串，输出它们相乘的结果的字符串
 * 复数字符串用a+bi表示(a, b 为整数, i为虚数单位，i2=1)
 * User:yxd
 * Date:2022-03-21
 * Time:22:04
 */
public class Bilibili2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String a = input.next();
        String b = input.next();
        int a1 = change(a.substring(0,a.indexOf("+")));
        int a2 = change(a.substring(a.indexOf("+") + 1));
        int b1 = change(b.substring(0,b.indexOf("+")));
        int b2 = change(b.substring(b.indexOf("+") + 1));
        int count1 = a1 * b1 + a2 * b2 * (-1);
        int count2 = a1 * b2 + a2 * b1;
        System.out.println(count1 + "+" + count2 + "i");

    }
    public static int change(String s){//取得数字
        int num = 0;
        int i = 0;
        int bool = 1;

        if(s.charAt(i) == '-'){
            bool = -1;
            i++;
        }
        int len = s.length();
        if(s.charAt(s.length() - 1) == 'i'){
            len = len - 1;
        }
        num = Integer.parseInt(s.substring(i,len));
        return num * bool;

    }

}
